


function [y1 y2 y3 y4 y5]=evaluate_pred_rewt_comm(y, y_pred, S_unsigned, pi)

%This routine calculates the error rates and the expected utility
%associated with the predictions/decisions contained in y_pred

TP=sum( (y==1)&(y_pred==1) )/sum(y==1);
TN=sum( (y==-1)&(y_pred==-1) )/sum(y==-1);
FP=sum( (y==-1)&(y_pred==1) )/sum(y==-1);
FN=sum( (y==1)&(y_pred==-1) )/sum(y==1);

Score=( pi/sum(y==1) )*sum( S_unsigned.*y_pred.*(y==1) ) + ( (1-pi)/sum(y==-1) )*sum( S_unsigned.*y_pred.*(y==-1) );
Score=(1/4)*Score - (1/4)*( ( pi/sum(y==1) )*sum( S_unsigned.*(y==1) ) + ( (1-pi)/sum(y==-1) )*sum( S_unsigned.*(y==-1) ) );
%Score=(1/4)*Score + (1/4)*( ( pi/sum(y==1) )*sum( S_unsigned.*(y==1) ) + ( (1-pi)/sum(y==-1) )*sum( S_unsigned.*(y==-1) ) );
%Score=( sum(  S_unsigned.*y_pred  )/N - sum(S_unsigned)/N  )/4;

%Note: expected utility is calculated under the assumption that the utility
%of action a=1 (preferred when Y=1) is normalized to zero. See Lieli and
%Springborn (2011) Tables 1 and 2. 

y1=Score;
y2=TP;
y3=TN;
y4=FP;
y5=FN;



